package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdDistributionMapper;
import com.diankangwo.factory.entity.TdDistribution;
import com.diankangwo.factory.service.TdDistributionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/** 佣金明细接口实现类
 * Created by wuye on 2017/10/17.
 */
@Service("TdDistributionService")
public class TdDistributionServiceImpl implements TdDistributionService {

    @Autowired
    private TdDistributionMapper mapper;

    /**
     * 保存一条佣金明细
     * @param tdDistribution
     */
    @Override
    @Transactional
    public void save(TdDistribution tdDistribution) {
        mapper.insert(tdDistribution);
    }

    /**
     * 修改一条佣金明细
     * @param tdDistribution
     * @return
     */
    @Override
    @Transactional
    public int update(TdDistribution tdDistribution) {
        return mapper.updateByPrimaryKey(tdDistribution);
    }

    /**
     * 根据ID删除
     * @param id
     */
    @Override
    @Transactional
    public void delete(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    /**
     * 根据条件获取佣金明细列表
     * @param map
     * @return
     */
    @Override
    public List<TdDistribution> queryList(Map<String, Object> map) {
        return mapper.queryList(map);
    }

    @Override
    public List<TdDistribution> queryList2(Map<String, Object> map) {
        return mapper.queryList2(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return mapper.queryTotal(map);
    }

    @Override
    public int queryTotal2(Map<String, Object> map) {
        return mapper.queryTotal2(map);
    }

    /**
     * 根据抽佣用户查询该用户佣金交易明细
     * @param prizeuserid
     * @return
     */
    @Override
    public List<TdDistribution> queryByprizeuserid(int prizeuserid) {
        return mapper.queryByprizeuserid(prizeuserid);
    }

    /**
     * 根据抽佣用户ID查询累计佣金
     * @param prizeuserid
     * @return
     */
    @Override
    public Float queryByPrizeuseSumMoney(Integer prizeuserid) {
        return mapper.queryByPrizeuseSumMoney(prizeuserid);
    }

    /**
     * 根据抽佣用户ID查询已结算佣金
     * @param prizeuserid
     * @return
     */
    @Override
    public Float queryByPrizeusePayMoney(Integer prizeuserid) {
        return mapper.queryByPrizeusePayMoney(prizeuserid);
    }

}
